<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-do-edit" th:object="${tbAddress}">
        <input type="hidden" name="id" th:value="*{id}"><!-- 主键 -->
        <div class="form-group">
            <label class="col-sm-3 control-label">属于哪个用户的地址:</label>
            <div class="col-sm-8"><input class="form-control" type="text" name="ownName" th:value="*{ownName}"></div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">收货人:</label>
            <div class="col-sm-8"><input class="form-control" type="text" name="consignee" th:value="*{consignee}"></div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">收货电话:</label>
            <div class="col-sm-8"><input class="form-control" type="text" name="phone" th:value="*{phone}"></div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">收货地址:</label>
            <div class="col-sm-8"><input class="form-control" type="text" name="addressDetail" th:value="*{addressDetail}"></div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">是否默认，0，不是，默认是1:</label>
            <div class="col-sm-8"><input class="form-control" type="text" name="isDefault" th:value="*{isDefault}"></div>
        </div>
        <div class="form-group">
            <div class="form-control-static col-sm-offset-9">
                <button type="submit" class="btn btn-primary">提交</button>
                <button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
            </div>
        </div>
    </form>
</div>
<div th:include="include::footer"></div>
<script th:src="@{/ajax/libs/select/select2.js}"></script>
<script type="text/javascript">
    layui.use('laydate', function () {
        var laydate = layui.laydate;//时间选择器
        laydate.render({
            elem: '#inDate', type: 'date'
        });
    });
    var prefix = "/tbAddress"
    $("#form-do-edit").validate({
        rules: {
            id: {required: true},
        },
        messages: {
            "id": {remote: "必填"}
        },
        submitHandler: function (form) {
            $.operate.save(prefix + "/editSave", dataEdit());
        }
    });

    function dataEdit() {
        var id = $("input[name='id']").val();
        var ownName = $("input[name='ownName']").val();
        var consignee = $("input[name='consignee']").val();
        var phone = $("input[name='phone']").val();
        var addressDetail = $("input[name='addressDetail']").val();
        var isDefault = $("input[name='isDefault']").val();
        return {
            "id":id,
            "ownName":ownName,
            "consignee":consignee,
            "phone":phone,
            "addressDetail":addressDetail,
            "isDefault":isDefault,
        }
    }
</script>
</body>
</html>